<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@taglib uri="http://www.springframework.org/tags/form" prefix="form"%>
<%@taglib uri="http://www.springframework.org/tags" prefix="spring"%>
<script type="text/javascript" charset="utf-8">
	$(document).ready(function() {
		$('#titles_id').dataTable({
			"bProcessing": true,
			"bJQueryUI": true,
			"bServerSide": true,
			"sAjaxDataProp": "rows",
			"aoColumns":[
		                {"mData":"titolo"},
		                {"mData":"autore"},
		                {"mData":"lingua"},
		                {"mData":"editore"},
		                {"mData":"id",
		                    "bSearchable": false,
		                    "bSortable": false,
		                    "sDefaultContent": "",
		                    "fnRender": function (oObj) {
		                       return "<a href='${pageContext.request.contextPath}/epubBiblio/download_start.do?id=" + oObj.aData['id'] + "'><span class='glyphicon glyphicon-download'><p class='text-justify'>Download</p></span></a>" + "&nbsp;&nbsp;|&nbsp;&nbsp;"+ 
		                       		  "<a href='${pageContext.request.contextPath}/epubBiblio/delete_start.do?id=" + oObj.aData['id'] + "'><span class='glyphicon glyphicon-remove'><p class='text-justify'>Cancella</p></span></a>";
		                    	
		                     }
		                  }
						],
            "sAjaxSource": "${pageContext.request.contextPath}/epubBiblio/findAllTitlesPaginated.do",
            "oLanguage": {"sUrl": "${pageContext.request.contextPath}/resources/datatables/i18n/italian.properties"},
            "fnServerParams": addsortparams
		});
	    
		
	});
</script>
<script type="text/javascript">
$(document).ready(function(){
	$("#xslt").click(function() {
		$.ajax({
			 url: "${pageContext.request.contextPath}/epubBiblio/XSlt.do",
			 
			 context: $("#stats"),
			 success: function(response){
				 	$('#stats').empty();
				 	
			        $('#stats').append(response);
			        $('#stats').parent().addClass('container');
					$('#colFirst').remove();
					$('#colLast').remove();
			        	$('#stats').parent().prepend('<div id="colFirst" class="col-md-1"></div>');
			        	$('#stats').parent().append('<div id="colLast"class="col-md-1"></div>');

			        	
			        
			        $('#stats').addClass('col-md-10');
			        $('small').css('font-size', '0.7em');
			        $('#tavola').addClass('table table-hover');
			        $('#tavola2').addClass( 'table table-hover');
			      }
		}).done(function(){
			console.log("fatto");
		});
	})
});

</script>
<div class="container">
	<div class="col-md-1">
	
	<span id="xslt" class="glyphicon glyphicon-hand-down"style="font-size: 0.7em;">Visualizza Statistiche</span></div>
	<div class="col-md-10">
	<form:form method="post" 
			   action="${pageContext.request.contextPath}${requestScope.action}"
			   commandName="myform" enctype="multipart/form-data">
			    
		<div class="well">
		 		<div class="form-group">
					<p style="font-size: 0.7em;">Inserisci nuovi Epub nella tua collezione</p>
					<form:input path="ePubFiles" type="file" class="btn btn-default" multiple="multiple"/>
			        
				
					<button type="submit" class="btn btn-primary start">Inserisci Nuovi ePub</button>
					<br>
					<form:errors path="ePubFiles" />
					
				</div>
		</div>
		
	</form:form>
	
	</div>
	<div class="col-md-1"></div>	
</div>



<div class="container">
<div class="col-md-1"></div>
<div class="col-md-10">
	<table id="titles_id">
	    <thead>
	        <tr>
	            <th>Titolo</th>
	            <th>Autore</th>
	            <th>Lingua</th>
	            <th>Editore</th>
	            <th>Azioni</th>
	        </tr>
	    </thead>
	    <tbody>
	    </tbody>
	</table>
</div>	
</div>


<div>
	<div id="stats">
	</div>
</div>
